package channelEntity

import "sync"

type channelEntityMap struct {
	mutex sync.RWMutex
	datas map[string]*SerialChannelEntity
}

func (e *channelEntityMap) Set(channelName string, channelEntity *SerialChannelEntity) {
	e.mutex.Lock()
	defer e.mutex.Unlock()
	e.datas[channelName] = channelEntity
}

func (e *channelEntityMap) Get(channelName string) *SerialChannelEntity {
	e.mutex.Lock()
	defer e.mutex.Unlock()

	return e.datas[channelName]
}

func (e *channelEntityMap) Remove(channelName string) {
	e.mutex.Lock()
	defer e.mutex.Unlock()

	delete(e.datas, channelName)
}
